home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / brk.man < prev    next >
Encoding:
Text File  |  1989-01-07  |  2.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. BRK                   C Library Procedures                    BRK
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      brk, sbrk - change data segment size
  10.  
  11. SSYYNNOOPPSSIISS
  12.      #include <sys/types.h>
  13.  
  14.      cchhaarr **bbrrkk((aaddddrr))
  15.      cchhaarr **aaddddrr;;
  16.  
  17.      cchhaarr **ssbbrrkk((iinnccrr))
  18.      iinntt iinnccrr;;
  19.  
  20. DDEESSCCRRIIPPTTIIOONN
  21.      _B_r_k sets the system's idea of the lowest data segment loca-
  22.      tion not used by the program (called the break) to _a_d_d_r
  23.      (rounded up to the next multiple of the system's page size).
  24.      Locations greater than _a_d_d_r and below the stack pointer are
  25.      not in the address space and will thus cause a memory viola-
  26.      tion if accessed.
  27.  
  28.      In the alternate function _s_b_r_k, _i_n_c_r more bytes are added to
  29.      the program's data space and a pointer to the start of the
  30.      new area is returned.
  31.  
  32.      When a program begins execution via _e_x_e_c_v_e the break is set
  33.      at the highest location defined by the program and data
  34.      storage areas.  Ordinarily, therefore, only programs with
  35.      growing data areas need to use _s_b_r_k.
  36.  
  37.      The current value of the program break is reliably returned
  38.      by ``sbrk(0)'' (see also _e_n_d(3)).  The _g_e_t_r_l_i_m_i_t(2) system
  39.      call may be used to determine the maximum permissible size
  40.      of the _d_a_t_a segment; it will not be possible to set the
  41.      break beyond the _r_l_i_m__m_a_x value returned from a call to
  42.      _g_e_t_r_l_i_m_i_t, e.g. "etext + rlp->rlim_max." (see _e_n_d(3) for the
  43.      definition of _e_t_e_x_t).
  44.  
  45. RREETTUURRNN VVAALLUUEE
  46.      Zero is returned if the _b_r_k could be set; -1 if the program
  47.      requests more memory than the system limit.  _S_b_r_k returns -1
  48.      if the break could not be set.
  49.  
  50. EERRRROORRSS
  51.      _S_b_r_k will fail and no additional memory will be allocated if
  52.      one of the following are true:
  53.  
  54.      [ENOMEM]       The limit, as set by _s_e_t_r_l_i_m_i_t(2), was
  55.                     exceeded.
  56.  
  57.      [ENOMEM]       The maximum possible size of a data segment
  58.                     (compiled into the system) was exceeded.
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               June 17, 1986                         1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. BRK                   C Library Procedures                    BRK
  71.  
  72.  
  73.  
  74.      [ENOMEM]       Insufficient space existed in the swap area
  75.                     to support the expansion.
  76.  
  77. SSEEEE AALLSSOO
  78.      execve(2), getrlimit(2), malloc(3), end(3)
  79.  
  80. BBUUGGSS
  81.      Setting the break may fail due to a temporary lack of swap
  82.      space.  It is not possible to distinguish this from a
  83.      failure caused by exceeding the maximum size of the data
  84.      segment without consulting _g_e_t_r_l_i_m_i_t.
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               June 17, 1986                         2
  130.  
  131.  
  132.  
  133.